package com.example.easy.Controller;


import com.example.easy.Dto.FoodSafety;
import com.example.easy.Dto.HealthSecurity;
import com.example.easy.Service.myservice.FoodSafetyServise;
import com.example.easy.Service.myservice.HealthSecurityServise;
import com.example.easy.Tools.ResultCode;
import com.example.easy.mapper.FoodSafetyMapper;
import com.example.easy.mapper.HealthSecurityMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Scope("prototype")
@RestController
@Api(value = "HealthSecurity", description = "卫生安全")
@RequestMapping(value = "/healthSecurity")

public class HealthSecurityController {


    @Autowired
    HealthSecurityMapper healthSecurityMapper;


    @Autowired
    HealthSecurityServise healthSecurityServise;

    @ApiOperation(value = "增加卫生安全信息", notes = "增加食卫生安全信息")
    @RequestMapping(value = "/insHealthSecurity", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object insHealthSecurity(@RequestBody HealthSecurity healthSecurity) throws IOException {

        return ResultCode.SUCCESS.result(healthSecurityServise.insHealthSecurity(healthSecurity));

    }

    @ApiOperation(value = "修改卫生安全信息", notes = "修改卫生安全信息")
    @RequestMapping(value = "/updateHealthSecurity", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateHealthSecurity(@RequestBody HealthSecurity healthSecurity) throws IOException {

        return ResultCode.SUCCESS.result(healthSecurityServise.updateHealthSecurity(healthSecurity));

    }

    @ApiOperation(value = "删除卫生安全信息", notes = "删除卫生安全信息")
    @RequestMapping(value = "/deleteHealthSecurity", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object deleteHealthSecurity(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(healthSecurityServise.deleteHealthSecurity(number));

    }

    @ApiOperation(value = "查看卫生安全信息", notes = "查看卫生安全信息")
    @RequestMapping(value = "/selectHealthSecurity", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectHealthSecurity(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(healthSecurityServise.selectHealthSecurity(number));

    }

    @ApiOperation(value = "查看所有卫生安全信息", notes = "查看所有卫生安全信息")
    @RequestMapping(value = "/selectall", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectall() throws IOException {

        return ResultCode.SUCCESS.result(healthSecurityServise.selectall());

    }

}
